<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">

                <h:form>
                    <p:panel header="Department List" >
                        <h:panelGrid columns="2">
                            <h:outputLabel value="Institution :"/>
                            <p:autoComplete converter="institutionConverter" value="#{hrReportController.institution}"
                                            completeMethod="#{institutionController.completeCompany}" 
                                            forceSelection="true"
                                            var="vt" itemLabel="#{vt.name}" itemValue="#{vt}" />
                        </h:panelGrid>
                        <p:commandButton ajax="false" action="#{hrReportController.crateDepartmentList}" value="Fill" />
                        <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" >
                            <p:printer target="reportPrint"></p:printer>
                        </p:commandButton>
                        <p:commandButton actionListener="#{hrReportController.crateDepartmentList}" ajax="false" value="Excel" styleClass="noPrintButton"  >
                            <pe:exporter type="xlsx" target="tbl1" fileName="hr_report_department"  />
                        </p:commandButton> 


                        <p:panel id="reportPrint" styleClass="noBorder summeryBorder"  >
                            <p:dataTable value="#{hrReportController.selectDepartments}" var="d" id="tbl1" rowIndexVar="i">
                                <f:facet name="header" >
                                    <h:outputLabel value="#{sessionController.loggedUser.institution.name}" /><br></br>
                                    <p:outputLabel value="Department List" />
                                    <h:panelGroup rendered="#{hrReportController.institution ne null}" >
                                        <br/>
                                        <h:outputLabel value="#{hrReportController.institution.name}" />
                                        <br/>
                                    </h:panelGroup>
                                </f:facet>
                                <p:column headerText="No">
                                    <f:facet name="header" >
                                        <p:outputLabel value="No" />
                                    </f:facet>
                                    <p:outputLabel value="#{i+1}" />
                                </p:column>
                                <p:column headerText="Department Code" >
                                    <f:facet name="header" >
                                        <p:outputLabel value="Department Code" />
                                    </f:facet>
                                    <p:outputLabel value="#{d.departmentCode}" />
                                </p:column>
                                <p:column headerText="Department Name" >
                                    <f:facet name="header" >
                                        <p:outputLabel value="Department Name" />
                                    </f:facet>
                                    <p:outputLabel value="#{d.name}" />
                                </p:column>
                                <p:column headerText="Institution Name" >
                                    <f:facet name="header" >
                                        <p:outputLabel value="Institution Name" />
                                    </f:facet>
                                    <p:outputLabel value="#{d.institution.name}" />
                                </p:column>
                                <f:facet name="footer">
                                    <p:outputLabel value="Print By : #{sessionController.loggedUser.webUserPerson.name} - " />
                                    <p:outputLabel value="Print At : " />
                                    <p:outputLabel value="#{commonController.currentDateTime}" >
                                        <f:convertDateTime pattern="yyyy MMMM dd hh:mm:ss a " />
                                    </p:outputLabel>
                                </f:facet>
                            </p:dataTable>
                        </p:panel>
                    </p:panel>
                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
